package com.woniu.cinema.controller;

import java.util.List;

import com.woniu.cinema.vo.HallMovieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.HallMovie;
import com.woniu.cinema.service.HallMovieService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 电影和影厅排片Controller
 *
 * @author yy
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/cinema/hallmovie")
public class HallMovieController extends BaseController
{
    @Autowired
    private HallMovieService hallMovieService;

    /**
     * 查询电影和影厅排片列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HallMovie hallMovie)
    {
        startPage();
        List<HallMovie> list = hallMovieService.selectHallMovieList(hallMovie);
        return getDataTable(list);
    }

    /**
     * 导出电影和影厅排片列表
     */
    @Log(title = "电影和影厅排片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HallMovie hallMovie)
    {
        List<HallMovie> list = hallMovieService.selectHallMovieList(hallMovie);
        ExcelUtil<HallMovie> util = new ExcelUtil<HallMovie>(HallMovie.class);
        return util.exportExcel(list, "hallmovie");
    }

    /**
     * 获取电影和影厅排片详细信息
     */
    @GetMapping(value = "/{hallMovieId}")
    public AjaxResult getInfo(@PathVariable("hallMovieId") Integer hallMovieId)
    {
        return AjaxResult.success(hallMovieService.selectHallMovieById(hallMovieId));
    }
    @GetMapping(value = "web/queryHallMovieByCinemaId")
    public AjaxResult queryHallMovieByCinemaId(Integer cinemaId)
    {

        List<HallMovieVo> list =  hallMovieService.queryHallMovieByCinemaId(cinemaId);
        return AjaxResult.success(list);
    }

    @GetMapping(value = "web/queryHallMovieById")
    public AjaxResult queryHallMovieById(Integer hallMovieId)
    {
        return AjaxResult.success(hallMovieService.selectHallMovieById(hallMovieId));
    }

    @RequestMapping(value = "feign/queryHallMovieById")
    public HallMovie queryHallMovieById4Feign(@RequestParam("hallMovieId") Integer hallMovieId)
    {
        return hallMovieService.selectHallMovieById(hallMovieId);
    }

    /**
     * 新增电影和影厅排片
     */
    @Log(title = "电影和影厅排片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HallMovie hallMovie)
    {
        return toAjax(hallMovieService.insertHallMovie(hallMovie));
    }

    /**
     * 修改电影和影厅排片
     */
    @Log(title = "电影和影厅排片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HallMovie hallMovie)
    {
        return toAjax(hallMovieService.updateHallMovie(hallMovie));
    }

    /**
     * 删除电影和影厅排片
     */
    @Log(title = "电影和影厅排片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hallMovieIds}")
    public AjaxResult remove(@PathVariable Integer[] hallMovieIds)
    {
        return toAjax(hallMovieService.deleteHallMovieByIds(hallMovieIds));
    }
}
